package com.kitty.syn;
import java.util.*;
public class FirstRunnable implements Runnable {

	private List<String> list;
	private int size;
	private Runnable runnable;
	
	public FirstRunnable(List<String> list,int size) {
		this.list = list;
		this.size = size;
		
	}
	public void setRunnable(Runnable runnable) {
		this.runnable = runnable;
	}
	
	public void run() {
		System.out.println("firstRunnable...");
		/*
		for (int i = 0; i < this.size; i++) {
			this.list.add("first:" + i);
			System.out.println("first:" + i + this.list);
		}
		*/
		int i = 0;
		while (true) {
			this.list.add("first:" + i++);
			if (this.list.size() > this.size) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} else if (this.list.size() == this.size) {
				System.out.println("first:" + i + this.list);
			}
			
			
			 
		}
	}
	public String toString() {
		return this.list.toString();
	}
	 

}
